package com.truyen.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.truyen.persistence.dao.ContentAnhDepDao;
import com.truyen.persistence.entity.AnhDep;
import com.truyen.persistence.entity.ContentAnhDep;
import com.truyen.service.ContentAnhDepService;
import com.truyen.utils.PagingInfo;


@Service
public class ContentAnhDepServiceImpl implements ContentAnhDepService {
	
	@Autowired
	private ContentAnhDepDao contentAnhDepDao;

	@Override
	public void save(ContentAnhDep entity) {
		contentAnhDepDao.save(entity);
	}

	@Override
	public ContentAnhDep findById(Long id) {
		return contentAnhDepDao.findById(id);
	}

	@Override
	public List<ContentAnhDep> getAll() {
		return contentAnhDepDao.findAll();
	}

	@Override
	public ContentAnhDep findByProperty(String column, Object value) {
		List<ContentAnhDep> lst = contentAnhDepDao.findByProperty(column, value);
		return (lst.size()>0)?lst.get(0):null;
	}

	@Override
	public List<ContentAnhDep> getAllLst(String kwSearch, String sort, String sortBy,
			PagingInfo pInfo) {
		return contentAnhDepDao.getAllLst(kwSearch,sort,sortBy,pInfo);
	}

	@Override
	@Transactional
	public void delete(long id) {
		ContentAnhDep entity = findById(id);
		if(entity != null){
			contentAnhDepDao.delete(entity);
		}
	}

	@Override
	public List<ContentAnhDep> getLstByAnhDep(AnhDep anhDep, String kwSearch,
			String sort, String sortBy, PagingInfo pInfo) {
		return contentAnhDepDao.getLstByAnhDep(anhDep,kwSearch,sort,sortBy,pInfo);
	}


}
